package com.example.appstudy2405.utils;

import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Environment;
import android.util.Log;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public class ReadFileLocal {

    public String readFileFromLocal(String filePath) {
        String fullFilePath = Environment.getExternalStorageDirectory() + "/Documents/001&002－Excuse Me.lrc";
        return readFileContent(fullFilePath);
    }


    private String readFileContent(String filePath) {
        StringBuilder content = new StringBuilder();
        try {
            File file = new File(filePath);
            if (file.exists() && file.isFile()) {
                BufferedReader reader = new BufferedReader(new FileReader(file));
                String line;
                while ((line = reader.readLine()) != null) {
                    content.append(line).append("\n");
                }
                reader.close();
            }
        } catch (IOException e) {
            Log.e("ReadTxtActivity", "读取文件时发生错误：" + e.getMessage());
        }
        return content.toString();
    }
}
